<script type="text/javascript" src="__PUBLIC__/js/swfupload/swfupload.js"></script>
		<script type="text/javascript" src="__PUBLIC__/js/swfupload/swfupload.swfobject.js"></script>
		<script type="text/javascript" src="__PUBLIC__/js/swfupload/swfupload.queue.js"></script>
		<script type="text/javascript" src="__PUBLIC__/js/swfupload/fileprogress.js"></script>
		<script type="text/javascript" src="__PUBLIC__/js/swfupload/handlers.js"></script>
		
		<script type="text/javascript">
			// 移除一个附件
			function remove_product_att(e){
				$(e).parent().parent().remove();
			}
			
			//swf upload
			var swfu;
			
			SWFUpload.onload = function () {
				var settings = {
					flash_url : "__PUBLIC__/js/swfupload/swfupload.swf",
					//upload_url: "http://localhost/mpbar/upload.php",	// Relative to the SWF file
					upload_url: "__APP__/album/upload",
					post_params: {"PHPSESSID" : "<?php echo session_id(); ?>","uid":"<?php echo $_SESSION['authId']; ?>"},
					file_size_limit : "100 MB",
					file_types : "*.jpg;*.jpeg;*.gif;*.png",
					file_types_description: "图片文件",
					file_upload_limit : 100,
					file_queue_limit : 0,
					custom_settings : {
						progressTarget : "fsUploadProgress",
						cancelButtonId : "btnCancel"
					},
					debug: false,
			
					// Button Settings
					button_placeholder_id : "spanButtonPlaceholder",
					button_width: 80,
					button_height: 30,
					button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
					button_cursor: SWFUpload.CURSOR.HAND,
			
					// The event handler functions are defined in handlers.js
					swfupload_loaded_handler : swfUploadLoaded,
					file_queued_handler : fileQueued,
					file_queue_error_handler : fileQueueError,
					file_dialog_complete_handler : fileDialogComplete,
					upload_start_handler : uploadStart,
					upload_progress_handler : uploadProgress,
					upload_error_handler : uploadError,
					upload_success_handler : uploadSuccess,
					upload_complete_handler : uploadComplete,
					queue_complete_handler : queueComplete,	// Queue plugin event
					
					// SWFObject settings
					minimum_flash_version : "9.0.28",
					swfupload_pre_load_handler : swfUploadPreLoad,
					swfupload_load_failed_handler : swfUploadLoadFailed
				};
			
				swfu = new SWFUpload(settings);
				//alert(settings.upload_url);
			}
			// 消息框
			function loading(){
				 var o = $('#body_loading');
			     o.css("left",(($(document).width())/2-(parseInt(o.width())/2))+"px");
			     o.css("top",(($(document).height()+$(document).scrollTop())/2-(parseInt(o.height())/2))+"px");
				 o.fadeIn("fast");
			}
			
			// 消息框
			function loaded(){
				var o = $('#body_loading');
				o.fadeOut("fast");
			}
			
			// 删除单张已上传图片
			function deluppic(key){
				if(confirm('确定删除?')){
					$.ajax({
						url: '__APP__/album/delpic/file/'+key,
						cache: false,
						success: function(res){
							picslist();
						}
					});
				}
			}

			// 删除全部已经上传图片
			function delalluppic(){
				if(confirm('确定删除?')){
					$.ajax({
						url: '__APP__/album/delalluppic',
						cache: false,
						success: function(res){
							picslist();
						}
					});
				}
			}

			// 图片预览
			function showpic(event,imgsrc){	
				var left = event.clientX+document.body.scrollLeft+20;
				var top = event.clientY+document.body.scrollTop+20;
				$("#preview").css({left:left,top:top,display:""});
				$("#pic_a1").attr("src",imgsrc);
			}
			// 取消预览
			function hiddenpic(){
				$("#preview").css({display:"none"});
			}
			// 添加到缩略图
			function addhtml(id){
				$("#thumb").val(id);
				$("#thumb_pic_tr").show();
				$("#thumb_pic").attr("src","__PUBLIC__/{:C('DIR_UPLOAD_PATH')}/"+id);
			}
			
			// 加载已上传图片
			function picslist(){
				$.ajax({
					url: '__APP__/album/itemlist',
					cache: false,
					success: function(res){
						$('#pics_upload_list').html(res);
					}
				});
			}
		</script>